<% extends 'public/base.html'%>
<% block content %>
  <div class="content whisper-content layui-container">
    <div class="cont layui-row">
        <div class="whisper-list" id="whisper-list"></div>
       <div id="whipser-page" style="text-align: center;"></div>
    </div>
  </div>
  <script type="text/html" id="laytplCont">
    <div class="cont">
      <div class="img">
        <img src="{{d.avatar}}" alt="">
      </div>
      <div class="text">
        <p class="tit"><span class="name">{{d.name}}</span><span class="data">2018/06/06</span></p>
        <p class="ct">{{d.cont}}</p>
      </div>
    </div>
  </script>
<% endblock %>
<% block script%>
   function updateQueryStringParameter(uri, key, value) {
	if(!value) {
		return uri;
	}
	var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
	var separator = uri.indexOf('?') !== -1 ? "&" : "?";
	if (uri.match(re)) {
		return uri.replace(re, '$1' + key + "=" + value + '$2');
	}
	else {
		return uri + separator + key + "=" + value;
	}
}
      element = layui.element,laypage = layui.laypage,form = layui.form,menu = layui.menu;
      laypage.render({
        elem: 'whipser-page'
        ,count: << whisper_count >>//数据总数，从服务端得到
        ,jump: function(obj, first){
              $.ajax({
                url:"<< url_for('main.whisper') >>",
                type:'post',
                data:{page:obj.curr,limit:obj.limit},
                dataType:'json',
                success:function (res) {
                    if(res.status==0){
                      $('#whisper-list').html('');
                      $.each(res.data,function(index,item){
                        var html_data='<div class="item-box"><div class="item"><div class="whisper-title"><i class="layui-icon layui-icon-date"></i><span class="hour">'+item.time+'</span><span class="date">'+item.date+'</span></div><p class="text-cont">'+item.content+'</p><div class="op-list"><p class="like" data-id="praisePoints_'+item.id+'"><i class="layui-icon layui-icon-praise"></i><span> '+item.praisePoints+'</span></p></div></div></div>';
                      $('#whisper-list').append(html_data);
                      });
                      obj.count=res.whisper_count;
                    }
                    else{
                      layer.alert(res.msg)
                    }
                }
              })
          }
      });
      menu.init();
      menu.off();
<% endblock %>